package de.velvettear.bruteforce.util;

import java.io.File; 

import de.velvettear.bruteforce.kernel.Statics;

public class DirectoryHelper {

	public static File createTemporaryThreadDirectory(String threadName) {
		File directory = new File(System.getProperty("user.dir") + File.separator + Statics.FOLDER_TMP + File.separator + threadName);
		
		if (!directory.exists()) {
			directory.mkdirs();
		}
		
		return directory;
	}
	
	public static void deleteTemporaryThreadDirectory(String threadName) {
		File directory = new File(System.getProperty("user.dir") + File.separator + Statics.FOLDER_TMP + File.separator + threadName);
		
		if (directory.exists()) {
			directory.delete();
		}
	} 
	
	public static boolean createDirectories() {
		boolean bin = false;
		boolean tmp = false;
		
		File subdir = new File(System.getProperty("user.dir") + File.separator + Statics.FOLDER_BIN);
		if (!subdir.exists()) {
			bin = subdir.mkdirs();
		} else {
			bin = true;
		}
		
		subdir = new File(System.getProperty("user.dir") + File.separator + Statics.FOLDER_TMP);
		if (!subdir.exists()) {
			tmp = subdir.mkdirs();
		} else {
			tmp = true;
		}
		
		if (bin && tmp) {
			return true;
		} else {
			return false;
		}
	}
	
}
